#include <iostream>
#include <cstring>
#include <sys/socket.h>
#include <arpa/inet.h>

int main()
{
    // 创建套接字
    int sockfd = ::socket(AF_INET, SOCK_DGRAM, 0);

    sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(8080);
    addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    
    while (1)
    {
        char buffer[1024] = {0};
        scanf("%s", buffer);

        sendto(sockfd, buffer, strlen(buffer), 0, (struct sockaddr*)&addr, sizeof(addr));
        std::cout << "发送成功！！！" << std::endl;
    }
    
    return 0;
}